<template>
  <div class="mod-menu">
    <el-form :inline="true" :model="dataForm">
      <el-form-item label="注册手机号">
        <el-input v-model="pamars.platform_phone" placeholder="注册手机号" maxlength="11" clearable></el-input>
      </el-form-item>
      <el-form-item label="审核状态">
        <el-select v-model="pamars.state" placeholder="审核状态" clearable>
          <el-option label="待审核" :value="0"></el-option>
          <el-option label="审核通过" :value="1"></el-option>
          <el-option label="审核不通过" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addOrUpdateHandle()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" row-key="Id" border style="width: 100%; ">
      <el-table-column prop="name" header-align="center" label="网红信息">
        <template slot-scope="scope">
          <div v-if="scope.row.platform">平台 ：{{scope.row.platform.platform_value}}</div>
          <div v-if="scope.row.fanweight">粉丝数量 ：{{scope.row.fanweight.fanweight_value}}</div>
          <div>注册手机号码 ：{{scope.row.platform_phone}}</div>
          <div v-if="scope.row.content_direction">内容方向 ：{{scope.row.content_direction.content_direction_value}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="个人信息">
        <template slot-scope="scope">
          <div>姓名 ：{{scope.row.real_name}}</div>
          <div>手机号码 ：{{scope.row.mobile}}</div>
          <div>身份证号 ：{{scope.row.card}}</div>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="身份证图片">
        <template slot-scope="scope">
          　　　　<el-popover placement="top-start" trigger="hover">
            <a :href="scope.row.card_back_path" target="_blank" title="查看最大化图片"><img :src="scope.row.card_back_path" style="width: 300px;height: 300px" /></a>
            <img slot="reference" :src="scope.row.card_back_path" @click="$openImg(scope.row.card_back_path)" style="width: 50px;height: 50px; cursor:pointer" />

            <a :href="scope.row.card_front_path" target="_blank" title="查看最大化图片"><img :src="scope.row.card_front_path" style="width: 300px;height: 300px" /></a>
            <img slot="reference" :src="scope.row.card_front_path" @click="$openImg(scope.row.card_front_path)" style="width: 50px;height: 50px; cursor:pointer" />
          </el-popover>
          　　</template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="粉丝截图">
        <template slot-scope="scope">
          　　　　<el-popover placement="top-start" trigger="hover">
            <a :href="scope.row.fans_file_path" target="_blank" title="查看最大化图片"><img :src="scope.row.fans_file_path" style="width: 300px;height: 300px" /></a>
            <img slot="reference" :src="scope.row.fans_file_path" @click="$openImg(scope.row.fans_file_path)" style="width: 50px;height: 50px; cursor:pointer" />
          </el-popover>
          　　</template>
      </el-table-column>
      <el-table-column prop="state" align="center" header-align="center" label="审核状态" width="120px">
        <template slot-scope="scope">
          <span v-if="scope.row.state == 0">未审核</span>
          <span v-if="scope.row.state == 1">审核通过</span>
          <span v-if="scope.row.state == 2">审核不通过</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" label="操作">
        <template slot-scope="scope">
          <!--  查看里的点击事件 @click="seeMsg(scope.row.id)" -->
          <el-button type="text" size="small" @click="lookOver(scope.row.id,1)">查看</el-button>
          <el-button type="text" size="small" v-if="scope.row.state==0" @click="seeMsg(scope.row.id,scope.row.state)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pamars.page" :page-sizes="[10, 20, 50, 100]" :page-size="pamars.limit" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>

    <!-- 弹窗, 新增 / 修改 -->
    <ic-audit v-if="addOrUpdateVisible" @updataList="updataList" ref="icAudit"></ic-audit>
    <internetDetail v-if="details" ref="internetDetail"></internetDetail>
  </div>
</template>

<script>
import icAudit from './ic-audit'
import seviceApi from '@/api/serviceApi.js'
import internetDetail from './internet-detail.vue'

export default {
  data () {
    return {
      dataForm: {},
      details: false,
      pamars: {
        page: 1,
        limit: 10,
        shop_name: '',
        audit_status: '',
        state: '',
        platform_phone: ''
      },
      totalPage: 0,
      dataList: [

      ],
      dataListLoading: false,
      addOrUpdateVisible: false
    }
  },
  components: {
    icAudit,
    internetDetail
  },
  mounted () {
    this.getCelebrityList()
  },
  methods: {
    // 查看信息
    lookOver (id, type) {
      this.details = true
      this.$nextTick(() => {
        this.$refs.internetDetail.init(id, type)
      })
    },
    // 更新审批状态
    updataList (e) {
      console.log(e)
      this.getCelebrityList()
    },
    // 审核
    seeMsg (id, type) {
      console.log(id, type)
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.icAudit.init(id, type)
      })
    },

    // 审核动态
    statusFormatter (row, column) {
      let status = row.status
      if (status === 0) {
        return '待审核'
      } else if (status === 1) {
        return '审核通过'
      } else {
        return '审核不通过'
      }
    },
    // 新增 / 修改
    // 模糊查询
    addOrUpdateHandle () {
      this.pamars.page = 1
      this.getCelebrityList()
      // this.addOrUpdateVisible = true
      // this.$nextTick(() => {
      //   this.$refs.icAudit.init(id)
      // })
    },
    // 获取网红列表
    getCelebrityList () {
      seviceApi.celebrity(this.pamars).then(res => {
        console.log(res.data.page.list)
        if (res && res.status == 200) {
          this.dataList = res.data.page.list
          this.totalPage = res.data.page.totalCount
          console.log(this.dataList)
        }
      })
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pamars.limit = val
      this.getCelebrityList()
    },

    // 当前页
    currentChangeHandle (val) {
      this.pamars.page = val
      this.getCelebrityList()
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pamars.limit = val
      this.getCelebrityList()
    }
  }
}
</script>
<style lang="scss">
</style>
